//
//  DTagAnalysisItem.swift
//  Drop
//
//  Created by hushaohua on 2018/2/11.
//  Copyright © 2018年 init. All rights reserved.
//

import Foundation
import CoreData

//enum DTagAnalysisAttribute:String {
//    case Duration = "Duration"//seconds
//    case Drop = "Drop"//count
//    case Average = "Average"//average
//}

class DDateTagAnalysisItem{
    var dateString:String = "";
    var tagItems:[DTagAnalysisItem]?;
    var pieCharts:[HPieChartItem]?;
    var barCharts:[HBarChartItem]?;
    init() {
        
    }
}

extension Int64{
    func analysisDurationStringBySeconds() -> String{
        if (self < 60){
            return "1'";
        }else if (self < 3600){
            return "\(self / 60)'";
        }else{
            return "\(self / 3600):\((self % 3600)/60)'";
        }
    }
}

class DTagDateAnalysisItem{
    var dateString:String = "";
    var duration:Int64 = 0;
    var count:Int32 = 0;
    
    var beginDate:Date?;
    var endDate:Date?;
    
    func durationString() -> String{
        return duration.analysisDurationStringBySeconds();
    }
    func averageString() -> String{
        let average = duration / Int64(count);
        return average.analysisDurationStringBySeconds();
    }
}

class DTagAnalysisItem{
    var tagName:String = "";
    var duration:Int64 = 0;
    var count:Int32 = 0;
    var tagID:NSManagedObjectID?;
    var barItem:HBarChartItem?;
    
    var average:Int64{
        return self.duration / Int64(self.count);
    }
    
    var beginDate:Date?;
    var endDate:Date?;
    
    init() {
        
    }
    func durationString() -> String{
        return duration.analysisDurationStringBySeconds();
    }
    func averageString() -> String{
        return self.average.analysisDurationStringBySeconds();
    }
}
